/*
 * Distributed as part of Scalala, a linear algebra library.
 *
 * Copyright (C) 2008- Daniel Ramage
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 USA
 */
package scalala;
package tensor;
package domain;

/**
 * The domain of elements from a specific set.
 *
 * @author dramage
 */
case class SetDomain[@specialized(Int,Long) A](set : scala.collection.Set[A])
extends Domain1[A] with Domain1Like[A,SetDomain[A]] {

  override def size =
    set.size;

  override def foreach[O](fn : A=>O) =
    set.foreach(fn);

  override def iterator =
    set.iterator;

  override def contains(key : A) : Boolean =
    set.contains(key);

  override def equals(other : Any) = other match {
    case SetDomain(s) => this.set == s;
    case that : Domain[_] => super.equals(that);
    case _ => false;
  }
}

